
#include "mlx_Read.h"
#include "bsp_uart.h"

SPIInstance *mlx_spi1;
SPIInstance *mlx_spi2;
float angle[3];

void mlx_Read_Task(void)
{
    SPI_Init_Config_s config = {
        &hspi1,
        SPI1_CS_GPIO_Port,
        SPI1_CS_Pin,
        SPI_BLOCK_MODE,
        NULL,
        NULL
    };
    SPI_Init_Config_s config1 = {
        &hspi2,
        SPI2_CS_GPIO_Port,
        SPI2_CS_Pin,
        SPI_BLOCK_MODE,
        NULL,
        NULL
    };
    mlx_spi1 = SPIRegister(&config);
    mlx_spi2 = SPIRegister(&config1);
    // while(MLX90393_Start(mlx_spi1) != 0x91){}
    while(MLX90393_Start(mlx_spi2) != 0x91){}
    
}

void mlx_Read_loop(void)
{
    // MLX90393_GetData(angle);
    HAL_Delay(10);
}

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
    if(GPIO_Pin == SPI1_INT_Pin)
    {
        // MLX90393_GetData(mlx_spi1, angle);
    }
    if(GPIO_Pin == SPI2_INT_Pin)
    {
        // MLX90393_GetData(mlx_spi2, (angle+1));
    }
}
